﻿#pragma once
#include "Protocol.h"
#include <stdio.h>
#include <string>

namespace HadoopPipes {
	class DownwardProtocol;
	class UpwardProtocol;
	class TextProtocol: public Protocol {
	private:
		FILE* downStream;
		DownwardProtocol* handler;
		UpwardProtocol* uplink;
		std::string key;
		std::string value;

		int readUpto(std::string& buffer, const char* limit);

		static const char* delim;
	public:
		TextProtocol(FILE* down, DownwardProtocol* _handler, FILE* up) ;

		UpwardProtocol* getUplink() {
			return uplink;
		}

		virtual void nextEvent() ;

		virtual ~TextProtocol() ;

	};


}